package com.mobile.collect.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.mobile.collect.R;
import com.mobile.collect.beans.DevicePointInfo;
import com.mobile.collect.view.MyPointView;


/**
 * Created by Administrator on 2017/4/18.
 */

public class PointDialog extends Dialog{
    MyPointView pointView;
    DevicePointInfo pointInfo;
    View.OnClickListener onClickListener;
    boolean showUpdateBtn;

    public PointDialog(Context context,boolean showUpdateBtn, View.OnClickListener listener) {
        super(context, R.style.WinDialog);
        this.onClickListener = listener;
        this.showUpdateBtn = showUpdateBtn;
        setContentView(R.layout.dialog_point);
        init();
    }

    public void display() {
        Window dialogWindow = getWindow();
        //设置Dialog从窗体底部弹出
        dialogWindow.setGravity(Gravity.CENTER_VERTICAL);
        //获得窗体的属性
        WindowManager.LayoutParams lp = dialogWindow.getAttributes();
        lp.y = 0;//设置Dialog距离底部的距离
//       将属性设置给窗体
        dialogWindow.setAttributes(lp);
        show();//显示对话框
        if (!showUpdateBtn) {
            findViewById(R.id.updateTv).setVisibility(View.GONE);
        }
    }

    RecyclerView.OnScrollListener onScrollListener;


    private void init() {
        findViewById(R.id.x1Tv).setOnClickListener(onClickListener);
        findViewById(R.id.x2Tv).setOnClickListener(onClickListener);
        findViewById(R.id.x3Tv).setOnClickListener(onClickListener);
        findViewById(R.id.upTv).setOnClickListener(onClickListener);
        findViewById(R.id.leftTv).setOnClickListener(onClickListener);
        findViewById(R.id.rightTv).setOnClickListener(onClickListener);
        findViewById(R.id.bg1Tv).setOnClickListener(onClickListener);
        findViewById(R.id.downTv).setOnClickListener(onClickListener);
        findViewById(R.id.bg2Tv).setOnClickListener(onClickListener);
        findViewById(R.id.updateTv).setOnClickListener(onClickListener);
        findViewById(R.id.delTv).setOnClickListener(onClickListener);
        findViewById(R.id.coloseTv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

}
